iT邦幫忙

2025 iThome 鐵人賽

DAY 11
2

https://ithelp.ithome.com.tw/upload/images/20250925/20177944K2eudBflgA.jpg

https://ithelp.ithome.com.tw/upload/images/20250925/20177944AR9ex1cIp2.jpg

#include <vector>//1011 O(n log S) O(1)
using namespace std;
static inline bool feasible(const int* a, int n, int days, int C){
    int need = 1, cur = 0;
    for(int i=0;i<n;++i){
        int x = a[i];
        if(cur + x > C){
            if(++need > days) return false;
            cur = x;// start next day with this package
        }else{
            cur += x;
        }
    }
    return true;
}
class Solution{
public:
    int shipWithinDays(vector<int>& w, int days){
        const int n = (int)w.size();
        const int* a = w.data();
        int L = 0, S = 0;// single pass: lower bound=max weight, upper bound=sum (both fit 32-bit)
        for(int i=0;i<n;++i){ int x=a[i]; if(x>L) L=x; S += x; }
        int R = S;
        if(days == n) return L;
        if(days == 1) return R;
        while(L < R){
            int m = (L + R) / 2;
            if(feasible(a, n, days, m)) R = m;  // feasible → try smaller
            else                      L = m + 1;// infeasible → increase
        }
        return L;// minimal feasible capacity
    }
};

上一篇
Binary Search 6->7 & 雞排好厚:)
下一篇
Binary Search 8 again review code contain & 周一放假但更期待收到錢錢的那一刻XD
系列文
轉職仔之Data Science and ai master後的持續精進技術之路12
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

1
AndyAWD
iT邦新手 2 級 ‧ 2025-09-25 23:19:20

Gemini CLI 表示:

✦ 當然,要讓咳嗽快點好,可以從幾個方面著手,結合居家照護、飲食調整和生活習慣改變。

請注意:我是一個AI助理,以下的建議不能取代專業醫療診斷。如果咳嗽持續、惡化,或伴隨高燒、呼吸困難等嚴重症狀
,請務必諮詢醫生。

這裡為您整理出一些最有效且公認的方法,可以分為幾個大類:

一、 立即舒緩與居家照護 (Immediate Relief & Home Care)

  1. 補充大量溫熱水分 (Stay Hydrated with Warm Fluids)
  2. 溫鹽水漱口 (Gargle with Salt Water)
  3. 蜂蜜檸檬水 (Honey and Lemon)
  4. 提高空氣濕度 (Increase Humidity)
  5. 墊高頭部睡覺 (Elevate Your Head While Sleeping)
  6. 避免刺激性食物 (Avoid Irritants)
  7. 攝取清淡、溫潤的食物 (Eat Soothing Foods)
  8. 充足的休息 (Get Plenty of Rest)
  9. 遠離過敏原與刺激物 (Stay Away from Triggers)
    三、 何時應該去看醫生? (When to See a Doctor)
  • 咳嗽持續超過兩週。
    總結來說,多喝溫水、充分休息、保持喉嚨濕潤
    是讓咳嗽快點好的三大黃金法則。希望這些建議能幫助您,祝您早日康復!

看來參加鐵人賽並沒有幫助

挖剛看留言期間邊吃完一個快樂的健達巧克力 哈

我要留言

立即登入留言